/*
 * Copyright 2009 Prime Technology.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.cefolim.util;

import javax.faces.application.FacesMessage;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;

//import org.primefaces.component.picklist.PickList;
//import org.primefaces.model.DualListModel;

import com.cefolim.model.Departement;

public class FaitConverter implements Converter {

	public FaitConverter() {
	}

    /**
     * get as object
     */
	public Object getAsObject(FacesContext facesContext, UIComponent arg1,
			String arg2) {
		Object ret = null;
		/*
		 * if (arg1 instanceof PickList) { Object dualList = ((PickList)
		 * arg1).getValue(); DualListModel dl = (DualListModel) dualList; for
		 * (Object o : dl.getSource()) { String id = "" + ((Fait)
		 * o).getCodeFait(); if (arg2.equals(id)) { ret = o; break; } } if (ret
		 * == null) for (Object o : dl.getTarget()) { String id = "" + ((Fait)
		 * o).getCodeFait(); if (arg2.equals(id)) { ret = o; break; } } }
		 */
		return ret;

	}
	
	/*
	 * (non-Javadoc)
	 * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
	 */
	public String getAsString(FacesContext facesContext, UIComponent component,
			Object value) {
		if (value == null || value.equals("")) {
			return "";
		} else {
			// return String.valueOf(((Fait) value).getCodeFait());
			return null;
		}
	}
}
